package com.sismul;

import java.io.File;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Environment;
import android.view.Window;

public class App {
	
	public static void showDialog(final Context context, String message, final boolean isFinish) {
		AlertDialog alertDialog = new AlertDialog.Builder(context).create();
		alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		//alertDialog.setTitle("Login Failed");
		alertDialog.setMessage(message);
		alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				if (isFinish)
					((Activity) context).finish();
				return;
			}
		});
		alertDialog.show();
	}
	
	public static String getFilename() {
		String filepath = Environment.getExternalStorageDirectory().getPath();
		File file = new File(filepath, "parrotificial");

		if (!file.exists()) {
			file.mkdirs();
		}

		return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + Constants.AUDIO_RECORDER_FILE_EXT_WAV);
	}
}
